import { createStore } from "vuex";
import createPersistedState from "vuex-persistedstate";
import { Tabs } from "../types/utils.interface";
import router from "./modules/route";
export default createStore({
  plugins: [
    createPersistedState({
      key: "ribbit-client",
      paths: ["tabslist"],
    }),
  ],
  modules: {
    router,
  },
  state: {
    tabslist: [
      {
        title: "控制台",
        path: "/",
        closable: false,
        key: "1",
      },
    ] as Tabs[],
    RouterList: [],
  },
  mutations: {
    setTabsList(state, val: Tabs) {
      state.tabslist.push(val);
    },
    updateTabsList(state, targetKey: string) {
      state.tabslist = state.tabslist.filter((pane) => pane.path !== targetKey);
    },
  },
});
